package com.enniswu.weitter.widget;

import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;

import com.enniswu.weitter.R;
import com.enniswu.weitter.user.start.StartActivity;

public class AlertLoginDialog extends DialogFragment {

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return new AlertDialog.Builder(getContext())
                .setTitle(R.string.alert_login_title)
                .setMessage(R.string.alert_login_message)
                .setNegativeButton(R.string.bt_cancel, negativeListener)
                .setPositiveButton(R.string.bt_ok, positiveListener)
                .create();
    }

    private DialogInterface.OnClickListener negativeListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dismiss();
        }
    };

    private DialogInterface.OnClickListener positiveListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            startActivity(new Intent(getContext(), StartActivity.class));
        }
    };
}
